package com.project.enums;

/**
 * 审批结果
 */
public enum DecisionEnum {
    PASS(1, "通过"),
    REFUSE(2, "拒绝"),
    NOT(0,"未审批");

    private final int code;
    private final String name;

    DecisionEnum(int code, String name) {

        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    // 根据 code 获取枚举（用于数据库反查）
    public static DecisionEnum fromCode(int code) {
        for (DecisionEnum status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知审批状态码: " + code);
    }

    // 根据 code 获取名称（直接供外部调用）
    public static String getStatusName(int code) {

        return fromCode(code).name;
    }
}
